﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<%@ Import Namespace="Amazon.SimpleDB"%>
<%@ Import Namespace="Amazon.SimpleDB.Model"%>
<%@ Import Namespace="Amazon.SimpleDB.Util"%>

<asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server">
    Home Page
</asp:Content>

<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Auctions ending soon!</h2>
    <div>
        <%
            List<Item> top10 = ViewData["Top10Items"] as List<Item>;
            
            foreach (Item item in top10)
            {
                //
                // Hash our attributes to make them easier to access
                //
                Dictionary<string, string> attributes = new Dictionary<string,string>();
                
                foreach (Amazon.SimpleDB.Model.Attribute attribute in item.Attribute)                    
                {
                    //
                    // Bid is a MVA, we can just ignore it for now, bids only really matter in the details view
                    //
                    if (attribute.Name.Equals("bids") == false)
                    {
                        attributes.Add(attribute.Name, attribute.Value);
                    }                    
                }
                
        %>
                <div class="auction">
                <fieldset class="auction">
                <legend><a href="/Auction/Details/<%=item.Name%>"><%=Html.Encode(attributes["name"]) %></a></legend>
                    <div>
                        <img src="<%=attributes["image"]%>" alt="image"/>
                    </div>
                </fieldset>                
                </div>
        <%
            }
        %>
    </div>
</asp:Content>
